#include "game-manager.hh"

GameManager::GameManager ()
  : ai_h_ (new AIHandler ())
{}

GameManager::~GameManager ()
{}

Player*
GameManager::operator() (int player_id)
{
  if (player_id < (int) player_list_.size ())
    return player_list_[player_id];
  else
    {
      assert (player_id < (int) player_list_.size ());
      return 0;
    }
}

bool
GameManager::is_winner ()
{
  bool won = false;

  for (int i = 0; i < (int) player_list_.size (); ++i)
    {
      if (player_list_[i]->building_list ().size () == 0 &&
	  player_list_[i]->unit_list ().size () == 0)
	;
      else
	{
	  if (won)
	    {
	      won = false;
	      winner_ = -1;
	      break;
	    }
	  else
	    {
	      won = true;
	      winner_ = i;
	    }
	}
    }

  return won;
}
